"""
    @Author  ：思念 
    @File    ：2.付费代理测试.py
    @Date    ：2025/4/10 9:20 
"""
import  requests

# 提取代理API接口，获取1个代理IP
ip_api_url = 'https://dps.kdlapi.com/api/getdps/?secret_id=oryqtk04nf6tmcqfmc9i&signature=orv8focd0ej2ccviunlw4xlcrw&num=1&pt=1&format=text&sep=1'
# 获取API接口返回的代理IP
proxy_ip = requests.get(ip_api_url).text
print('获取的IP为：',proxy_ip)

# 用户名密码认证(私密代理/独享代理)
username = "d2229184921"
password = "miss1234"
proxies = {
    "http": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip},
    "https": "http://%(user)s:%(pwd)s@%(proxy)s/" % {"user": username, "pwd": password, "proxy": proxy_ip}
}

# 要访问的目标网页
test_url = 'http://httpbin.org/ip'
# 使用代理IP发送请求
response = requests.get(test_url, proxies=proxies).text
# 获取页面内容
print("请求成功，页面内容：", response)

